<template>
  <view class="hisFoot">
    <view class="main" v-for="(item, index) in boxNameList" :key="index">
      <view class="head">
        <view class="min_box"></view>
        <view class="time">{{ item }}</view>
      </view>
      <view class="content">
        <view
          class="box"
          v-for="(key0, subIndex) in boxList[item]"
          :key="subIndex"
          @tap="jumpPage(key0)"
        >
          <img :src="key0.fullPath" alt="" />
          <view class="title">{{ key0.title }}</view>
        </view>
      </view>
    </view>
    <view class="bottom" v-if="boxNameList.length > 0"
      >到底啦，仅展示近三十天的记录欧~</view
    >
    <!-- 缺省页 -->
    <shopro-empty
      v-if="isEmpty"
      :image="
        $IMG_URL + '/uploads/20230527/2c41fead31f264cc3d655b7a0f805ba1.png'
      "
      tipText="世界那么大，多去看看吧~"
      btnText="去逛逛"
      @click="toIndex"
    ></shopro-empty>
  </view>
</template>
<script>
export default {
  // 建议 创建每个组件时 都添加name属性 标识组件名称
  name: '',
  components: {},
  data: () => ({
    boxList: [],
    //足迹名称
    boxNameList: [],
    isEmpty: false,
  }),
  // 计算属性 适配者模式
  computed: {},
  // 数据监听
  watch: {},

  onLoad() {},
  // 监听页面显示。页面每次出现在屏幕上都触发 包括从下级页面点返回露出当前页面
  onShow() {
    this.getFootmark();
  },
  // 监听页面初次渲染完成 注意如果渲染速度快，会在页面进入动画完成前触发
  onReady() {},
  // 监听页面隐藏
  onHide() {},
  // 监听页面卸载
  onUnload() {},
  methods: {
    getFootmark() {
      this.$http('v1.getFootmark', {}, '请稍等').then((res) => {
        if (res.code === 1) {
          let list = Object.keys(res.data);
          list.sort((a, b) => {
            let fir = new Date(a).getTime();
            let last = new Date(b).getTime();
            return last - fir;
          });
          this.boxList = res.data;
          this.boxNameList = list;
          this.isEmpty = this.boxNameList.length == 0 ? true : false;
        }
      });
    },
    //跳转活动页面
    jumpPage(e) {
      switch (e.activity_type) {
        case '1':
          uni.navigateTo({
            url: `/pages/rewardGoods/portrait/index?id=${e.activity_id}`,
          });

          break;
        case '2':
          uni.navigateTo({
            url: `/pages/fukubukuro/extract/extract?id=${e.activity_id}`,
          });
          break;
      }
    },
    //跳到首页
    toIndex() {
      uni.switchTab({
        url: 'pages/index/index',
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.hisFoot::before {
  content: ' ';
  position: absolute;
  left: 0;
  top: 12rpx;
  width: 1px;
  bottom: 0;
  border-left: 1px solid #ddd;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: scaleX(0.5);
  transform: scaleX(0.5);
  border-left-width: 1px;
  border-left-style: solid;
  border-left-color: rgb(221, 221, 221);
}
.hisFoot {
  height: 100%;
  margin: 30rpx;
  position: relative;
  // border-left: 2rpx solid #d7c9ff;
  .main {
    .head {
      display: flex;
      align-items: center;
      margin-left: -7rpx;
      margin-bottom: 13rpx;
      .min_box {
        width: 12rpx;
        height: 12rpx;
        background: #a084f0;
        border-radius: 50%;
        z-index: 999;
      }
      .time {
        font-size: 24rpx;
        font-family: Oswald-Bold, Oswald;
        font-weight: 700;
        color: #a084f0;
        margin-left: 21rpx;
      }
    }
    .content {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      border-top: 1rpx solid #f2f2f2;
      padding-left: 21rpx;
      .box {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-top: 25rpx;
        margin-bottom: 25rpx;
        margin-right: 13rpx;
        img {
          width: 207rpx;
          height: 192rpx;
          border-radius: 20rpx 20rpx 20rpx 20rpx;
        }
        .title {
          width: 207rpx;
          font-size: 24rpx;
          font-family: PingFang SC-Bold, PingFang SC;
          font-weight: 400;
          color: #3d3d3d;
          height: 34rpx;
          line-height: 34rpx;
          text-align: center;
          white-space: normal;
          overflow: hidden;
          text-overflow: ellipsis;
          margin-top: 8rpx;
        }
      }
    }
  }
  .bottom {
    height: 70rpx;
    width: 100%;
    border-top: 1rpx solid #f2f2f2;
    line-height: 70rpx;
    text-align: center;
    font-size: 20rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 400;
    color: #979797;
  }
}
</style>
